package aclass.rocksea.com.database.db;

import android.content.Context;

import com.litesuits.orm.LiteOrm;
import com.litesuits.orm.db.DataBaseConfig;

import java.util.ArrayList;

/**
 * Created by Mrw on 2017/7/5.
 *
 */

public class MessageDbHelper {

    private static LiteOrm mNoteDb;
    private static MessageDbHelper mMessageDbHelper;
    private MessageDbHelper(Context context) {
        //初始化数据库
        DataBaseConfig config = new DataBaseConfig(context);
        config.dbName = "Message.db";
        config.dbVersion = 1;
        mNoteDb = LiteOrm.newSingleInstance(config);
    }
    public static MessageDbHelper getInstance(Context context){
        if (mNoteDb==null){
            synchronized (MessageDbHelper.class){
                mMessageDbHelper =new MessageDbHelper(context);
            }
        }
        return mMessageDbHelper;
    }

    public void save(Message mMessage){
        mNoteDb.save(mMessage);
    }

    public ArrayList<Message> qurey(){
        return mNoteDb.query(Message.class);
    }


}
